package whu.cn.whushare.ui.common;

import android.app.Activity;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.WindowManager;

import whu.cn.whushare.R;
import whu.cn.whushare.common.UserManager;
import whu.cn.whushare.ui.main.MainTabActivity;
import whu.cn.whushare.ui.main.my.LoginActivity;

public class LoadingActivity extends Activity {
    private static final int MESSAGE_LOADING = 1;
    private UserManager mUserManager;
    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MESSAGE_LOADING:
                    jumpToLogin();
                    break;
            }
            super.handleMessage(msg);
        }
    };

    //跳转到登录页面
    private void jumpToLogin() {
        getIn();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_loading);
        handler.sendEmptyMessageDelayed(MESSAGE_LOADING, 1000);
    }

    //跳转到登录activity的方法
    private void getIn() {
        Intent i = LoginActivity.getStartIntent(this);
        startActivity(i);
        finish();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        getIn();
        return true;
    }

}
